package com.example.jixeishi1.controller;


import com.example.jixeishi1.service.CollService;

import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.List;


@Controller
//@SessionAttributes({"list"})
public class CollController {

    @Autowired
    CollService service;

    @RequestMapping("/getcoll")
    public String getCollection(@Param("id") int id,
                                @RequestParam(defaultValue = "1") int page, ModelMap map){
        System.out.println("id:"+id);
        PageInfo pageInfo=service.getCollection(id,page);
        map.put("pageInfo",pageInfo);
        List list=service.infopage(id,page);
        map.put("list",list);
        return "shoucang";
    }
    @RequestMapping("/delcoll")
    public String delCollection(@Param("id") int id,@Param("user_id") int user_id){
        System.out.println("id:"+id+"用户id:"+user_id);
        HashMap map=new HashMap();
        map.put("id",id);
        map.put("user_id",user_id);
        int n=service.delCollection(map);
        return "redirect:/getcoll?id="+user_id;
    }
}
